home *** CD-ROM | disk | FTP | other *** search
- /*-----------------------------------------------------------------
- Marathon data structures.
-
- The Map file consists of:
-
- mapHeader // only one header
-
- level data for level 1..n // data for each level.
-
- levelInfo[n] // trailer info. one level info for each level
-
-
- The level data consists of different chunks.
- Each chunk is defined below. Chunks can be in any order.
- Not all chunks are needed but some are.
- -----------------------------------------------------------------*/
- #pragma once
-
- #define MAX_VERTICIES 1024
- #define MAX_LINES 1024
- #define MAX_SIDES 1024
- #define MAX_POLYS 256
- #define MAX_LITES 32
- #define MAX_OBJECTS 256
- #define MAXIMUM_OBJECT_TYPES 64
-
- // this is what a map header looks like
- typedef struct {
- short type; // 0
- unsigned short flags; // 0
- char name[64]; // c string
- long unused;
- long mapSize; // offset to trailer info
- short numLevels; // number of levels in map
- short unused2[25]; // not exactly unused?????
- } mapHeader;
-
- // this is the level info, or trailer. One for each level
- typedef struct {
- long offset; // number of bytes from start of file
- long size; // size of level in bytes
- } levelInfo;
-
- // no longer used as level name. Now used as authors name.
- typedef char levelName[64];
-
- // a chunk header
- typedef struct {
- long chunkType; // type of chunk OSType
- long nextChunk; // offset from level start to next chunk. 0 if last.
- long size; // size of chunk data
- // chunk data is here
- } chunkHeader;
-
- // a point
- typedef struct {
- short x,y; // a signed value
- } PNTSdata;
-
- // flags for the end points
- enum { // vertex flags
- vertex_solid = 0x0001, // ????
- vertex_multiHeights = 0x002 // adjacent polys have different heights
- };
-
- // end points. Do not use. Use points instead.
- typedef struct {
- unsigned short flags; // vertex flags
- short highestFloor; // highest adjacent floor height
- short lowestCeiling; // lowest adjacent ceiling height
- short x, y;
- short transformedX, transformedY; // ????
- short polyIndex; // ????
- } EPNTdata;
-
- enum { // lines flags
- line_solid = 0x4000, // shots/player can not pass through
- line_transparent = 0x2000, // can see through, ie window
- line_landScaped = 0x1000,
- line_elevated = 0x0800,
- line_variableElevation =0x0400
- };
-
- // when going from point b->a is how left/right is determined.
- typedef struct {
- short pointA; // line goes from point a to b
- short pointB;
- unsigned short flags; // line flags
- short length; // length of line. MUST be calced
- short highestFloor; // highest adjacent floor height
- short lowestCeiling; // lowest adjacent ceiling height
- short leftSide; // the side on the left of the line (-1 for none)
- short rightSide;
- short leftPoly; // the poly on the left of the line (-1 for none)
- short rightPoly;
- short unused[6];
- } LINSdata;
-
- enum { // side flags
- side_ControlPanelStatus = 0x0001,
- side_ControlPanel = 0x0002,
- side_RepairSwitch = 0x0004
- };
- enum { // side types
- side_Full, // primary texture goes from ceiling to floor
- side_High, // primary texture goes from ceiling down
- side_Low, // primary texture goes from floor up
- side_Composite, // primary texture is from ceiling to floor, secondary texture is mapped on to it, ie control panel
- side_Split // primary from ceiling down, secondary from floor up
- };
- enum { // control panel types
- panel_Oxygen,
- panel_Shield,
- panel_DoubleShield,
- panel_TripleShield,
- panel_LightSwitch, // permutaion = light index
- panel_platformSwitch, // permutation = platform index??
- panel_PatternBuffer,
- panel_Unused,
- panel_CommTerminal, // permutation = script index
- panel_Switch, // usually a repair switch
- alienPanel_DoubleShield,
- alienPanel_TripleShield,
- alienPanel_platformSwitch,
- alienPanel_PatternBuffer
- };
- enum { // transfer modes for sides and polys
- tNormal, // normal texture mapping
- tFadeToBlack,
- tInvisible,
- tSubInvisible,
- tPulsate, /* polygons only */
- tWobble, /* polygons only */
- tFastWobble, /* polygons only */
- tStatic,
- tSubStatic,
- tLandscape, // copy, no texture mapping, for views outside of window
- tSmear, /* flat shading of pixel at 0,0 */
- tFadeOutStatic,
- tPulsateStatic,
- tFoldIn, // appear
- tFoldOut, // disappear
- tHorizSlide,
- tFastHorizSlide,
- tVertSlide,
- tFastVertSlide,
- tWander,
- tFastWander
- };
-
- // a texture.
- typedef struct {
- short xo, yo; // offsets into texture
- char textureSet; // texture set number
- char textureNum; // texture number in set
- } texture;
-
- // prevents the side from being passable. (?overhead area rectangle?)
- // bungi says do not use
- typedef struct {
- short x1, y1;
- short x2, y2;
- short x3, y3;
- short x4, y4;
- } exclusionZone;
-
- // the sides data
- typedef struct {
- short type;
- unsigned short flags;
- texture primaryTexture;
- texture secondaryTexture;
- texture transparentTexture;
- exclusionZone theExclusionZone; // do not use, set to -1
- short controlPanelType;
- short controlPanelPermutation;
- short primaryTransferMode;
- short secondaryTransferMode;
- short transparentTransferMode;
- unsigned short direction; // set to -1
- short lineIndex; // the line this side belongs to
- short unused[6];
- } SIDSdata;
-
- enum { // poly flags
- polygon_Detached = 0x4000,
- polygon_platformInitiallyOff = 0x2000,
- polygon_platformInitiallyExtended = 0x1000
- };
- enum { // poly types
- polygon_Normal,
- polygon_ItemImpassable,
- polygon_MonsterImpassable,
- polygon_MinorDamage,
- polygon_MajorDamage,
- polygon_platform, // permutation = platform index
- polygon_LightOnTrigger, // permutation = light index
- polygon_platformOnTrigger, // permutation = polygon index
- polygon_LightOffTrigger, // permutation = light index
- polygon_platformOffTrigger, // permutation = polygon index
- polygon_Teleporter, // permutation = polygon index
- polygon_Glue, // monsters stay deactive
- polygon_GlueTrigger, // triggers all glue
- polygon_Superglue,
- polygon_MustExplore, // must explore to end level
- polygon_Exit // if conditions met then teleport to next level
- };
-
- // same as texture set but no offset
- typedef struct {
- char set;
- char frame;
- } shapeDescriptor;
-
- // the polygon
- typedef struct {
- short type; // user editable
- unsigned short flags; // user editable
- short permutation; // user editable == platform number, light number
- short vertexCount; // number of points in poly
- short vertexIndex[8]; // the point array index
- short lineIndex[8]; // the line from point -> point + 1
- shapeDescriptor floorTexture; // user editable
- shapeDescriptor ceilingTexture; // user editable
- short floorHeight; // user editable
- short ceilingHeight; // user editable
- short floorLightSource; // user editable
- short ceilingLightSource; // user editable
- long area; // do we need to calc this????
- short firstObject; // -1
- short firstExclusionZoneIndex; // looks in the exclusion zone index array: -1
- short lineExclusionZoneCount; // 0
- short pointExclusionZoneCount; // 0
- short floorTransferMode; // user editable
- short ceilingTransferMode; // user editable
- short adjacentPolys[8]; // the poly on the other side of this line
- short firstNeighborIndex; // -1
- short neighborCount; // 0
- short centerX;
- short centerY;
- short sideIndex[8]; // the side on this line
- short unused[10];
- } POLYdata;
-
- enum { // lite flags
- light_Autotriggered = 0x4000
- };
- enum { // lite types
- light_Normal,
- light_Rheostat,
- light_Flourescent,
- light_Strobe,
- light_Flicker,
- light_Pulsate,
- light_Annoying,
- light_EnergyEfficient
- };
- enum { // lite modes
- light_TurningOn,
- light_On,
- light_TurningOff,
- light_Off,
- light_Toggle
- };
- // the lighting data
- typedef struct {
- unsigned short flags;
- short type;
- short mode;
- short phase;
- Fixed minIntensity;
- Fixed maxIntensity;
- short period;
- Fixed intensity;
- short unused[5];
- } LITEdata;
-
- enum { // object types
- object_monster = 0,
- object_scenery,
- object_weapon,
- object_player,
- object_goal // index = terminal data to display portions of map
- };
- // the objects
- typedef struct {
- short type;
- short index; // depends on type, but from 0..n
- short facing; // direction it is facing
- short polyIndex; // what polygon this is in
- short x; // its co-ords
- short y;
- short unused[2];
- } OBJSdata;
-
- enum { // mission flags
- mission_None = 0x0000,
- mission_Extermination = 0x0001,
- mission_Exploration = 0x0002,
- mission_Retrieval = 0x0004,
- mission_Repair = 0x0008,
- mission_Rescue = 0x0010
- };
- enum { // environment flags
- environment_Normal = 0x0000,
- environment_Vacuum = 0x0001,
- environment_Magnetic = 0x0002,
- environment_Rebellion = 0x0004,
- environment_LowGravity = 0x0008
- };
-
- enum { // player info - same as the game options
- player_single = 0x0001,
- player_MultiCoop = 0x0002,
- player_MultiCarnage = 0x0004
- };
-
- enum { // game options
- game_Multiplayer = 0x0001,
- game_ReplenishAmmo = 0x0002,
- game_ReplenishWeapons = 0x0004,
- game_ReplenishSpecials = 0x0008,
- game_ReplenishMonsters = 0x0010,
- game_NoMotionSensor = 0x0020,
- game_OmniscientMap = 0x0040,
- game_LoseItemsOnDeath = 0x0080,
- game_DebugMap = 0x0100,
- game_KillLimit = 0x0200,
- game_NoTeams = 0x0400,
- game_PenalizeDying = 0x0800,
- game_PenalizeSuicide = 0x1000,
- game_MapShowsItems = 0x2000,
- game_MapShowsMonsters = 0x4000,
- game_MapShowsProjectiles = 0x8000
- };
-
- // the mission info data
- typedef struct {
- short environmentCode;
- short physicsModel;
- short songIndex;
- unsigned short missionFlags;
- unsigned short environmentFlags;
- short unused[4];
- char levelName[64];
- long entryPointFlags;
- short playerInfo;
- } Minfdata;
-
- enum { // platform flags
- platform_InitiallyActive = 0x00000001, // inactive if 0
- platform_InitiallyExtended = 0x00000002, // high for floor... close for both
- platform_StopsAtEachLevel = 0x00000004, // deactivates when it reaches a discrete level.
- platform_StopsAtInitialLevel = 0x00000008, // deactivates when it returns to its initial level
- platform_ActivatesAdjacentUponDeactivating = 0x00000010, // activates adjacent platforms on deactivation
- platform_ExtendsFloorToCeiling = 0x00000020,
- platform_ExtendsFloor = 0x00000040, // extends from the floor
- platform_ExtendsCeiling = 0x00000080, // extends from the ceiling
- platform_CausesDamage = 0x00000100,
- platform_NoActivateParent = 0x00000200, // does not activate the platform that activated it
- platform_OneShot = 0x00000400,
- platform_ActivatesLight = 0x00000800, // activates floor and ceiling light source when activating
- platform_DeactivatesLight = 0x00001000, // deactivates ...
- platform_PlayerControllable = 0x00002000, // player can use action key to start and stop
- platform_MonsterControllable = 0x00004000,
- platform_Safety = 0x00008000, // reverses direction when obstructed
- platform_NoExternalActivate = 0x00010000, // when active can only be deactivated by itself
- platform_UsesNativeHeights = 0x00020000, // complex calcs
- platform_DelaysBeforeActivate = 0x00040000, // waits max delay before activating
- platform_ActivatesAdjacentUponActivating = 0x00080000, // activates adjacent plats when activating
- platform_DeactivatesAdjacentUponActivating = 0x00100000,
- platform_DeactivatesAdjacentUponDeactivating = 0x00200000,
- platform_ContractsSlow = 0x00400000,
- platform_ActivatesAdjacentOnEachLevel = 0x00800000, // activates adjacent on each level
- platform_Floods = 0x01000000, // floor texture changes when at bottom
- platform_Secret = 0x02000000 // ? doesnt show up on map?
- };
-
- #if 0
- enum /* platform types */
- {
- _platform_is_marathon_door,
- _platform_is_marathon_platform,
- _platform_is_noisy_marathon_platform,
- _platform_is_alien_door,
- _platform_is_alien_platform,
- _platform_is_noisy_alien_platform,
- NUMBER_OF_PLATFORM_TYPES
- };
- #endif
-
- // the platform data
- typedef struct {
- short type;
- short speed;
- short delay;
- short maxHeight; // calced for you if ommited, -1
- short minHeight; // calced for you if ommited, -1
- unsigned long flags;
- short ownerPolygonIndex;
- short unused[8];
- } platdata;
-
- enum // flags for object_frequency_definition
- {
- _reappears_in_random_location= 0x0001
- };
-
- #define _random_location_off_mask 0xFFFE
-
- // there are 128 of these. Monsters are the first 64, and items the second 64
- typedef struct {
- short flags;
- short initial_count; // initial qty. (can be greater than maximum_count)
- short minimum_count; // qty > this
- short maximum_count; // qty < this
- short random_count; // maximum random occurences of the object UInt16 random_chance; // in (0, 65535]
- short frequency;
- } placData;
-
- // the notes that appear in the map view
- typedef struct {
- short type; // set to 0
- short x;
- short y;
- short polyNum; // the poly the x,y coords end up in
- char text[64]; // the text
- } NOTEdata;
-
-
- // the level data after it is read in from disk
- // this is how the level is stored in ram.
- typedef struct {
- long numPoints;
- PNTSdata *thePoints;
- long numExtendedPts; // actually are called end points
- EPNTdata *theExtendedPts;
- long numLines;
- LINSdata *theLines;
- long numSides;
- SIDSdata *theSides;
- long numPolys;
- POLYdata *thePolys;
- long numLites;
- LITEdata *theLites;
- long numObjects;
- OBJSdata *theObjects;
- long numMinfos;
- Minfdata *theMissionInfo;
- long numPlatforms;
- platdata *thePlatforms;
- long numiidxs; // after I know what all these are then...
- Ptr theiidxs; // do not put these into the map file!!!!!!
- long numNOTEs;
- NOTEdata *theNOTEs;
- long numplacs;
- placData *theplacs;
- short numNames;
- levelName *levelAuthor;
- Handle terminalTexts[10]; // the text for the terminal messages
- Boolean readIn; // has this level been read in once yet?
- Boolean deleteMe; // should we write out this level?
- mapHeader *theMapHeader;
- Ptr ownerDocument; // an editorDoc instance that owns this map
- } levelData;
-
- // the map file. Not all levels need to be in memory
- typedef struct {
- mapHeader theMapHeader;
- levelInfo *theLevelInfo;
- levelData **theLevelData;
- } marathonMap;
-
-
-
-